import { NextApiRequest, NextApiResponse } from "next";

import { createDataset } from "@/services";

async function createNewDataset(
  req: NextApiRequest,
  res: NextApiResponse<APIRes>
) {
  await createDataset(req, res);
}

export default async function handler(
  req: NextApiRequest,
  res: NextApiResponse<APIRes>
) {
  if (req.method === "POST") {
    createNewDataset(req, res);
  } else {
    res.status(405).json({
      success: false,
      data: {},
      message: "Method not allowed",
    });
  }
}
